import { getAction, putAction, postAction } from '@/api/manage'
import { serviceApi } from '@/api/common.js'

export const api = {
  list: serviceApi.auth + '/devices/functions',
  delete: (ids) => serviceApi.auth + `/devices/functions/${ids}`,
  deleteBatch: serviceApi.auth + '/devices/functions/delete-batch',
  add: serviceApi.auth + '/devices/functions',
  edit: serviceApi.auth + '/devices/functions'
}

/**
 * 添加
 * @param parameter
 * @returns {*}
 */
export const addDeviceFunc = params => postAction(api.add, params);

/**
* 编辑
* @param parameter
* @returns {*}
*/
export const editDeviceFunc = params => putAction(api.edit, params);

/**
 * 设备功能根目录数据
 * @param parameter
 * @returns {*}
 */
export const getRootList = params => getAction(api.list, params);

/**
 * 设备功能子目录数据
 * @param parameter
 * @returns {*}
 */
export const getChildList = (pid, params) => getAction(serviceApi.auth + `/devices/functions/children/${pid}`, params);

/**
* 删除
* @param parameter
* @returns {*}
*/
export const getChildListBatch = (params) => getAction(serviceApi.auth + '/devices/functions/children/batch', params);

/**
 * 获取设备类型
 * @param {*} params
 * @returns
 */
export const getDeviceTypeList = params => getAction(serviceApi.auth + '/assets/devices/types', params);

/**
 * 验证设备类型功能编号
 * @param {*} params
 * @returns
 */
export const funcCheckCode = params => getAction(serviceApi.auth + '/devices/functions/code-check', params);
